package fons.navigator.ui.browsers.dimensions;

import edu.umd.cs.piccolo.PCamera;
import edu.umd.cs.piccolo.event.PBasicInputEventHandler;
import edu.umd.cs.piccolo.event.PInputEvent;
import fons.navigator.util.piccolo.ContextMenu;

public class ConnectionMenu extends ContextMenu {
	private static final long serialVersionUID = 1L;
	
	private final Block startingBlock, targetBlock;
	private final Runnable finished;
	
	public ConnectionMenu(PCamera camera, Block start, Block target, Runnable finished) {
		super(camera);
		this.startingBlock = start;
		this.targetBlock = target;
		this.finished = finished;
		
		this.addInputEventListener(new PBasicInputEventHandler() {
			@Override
			public void mouseClicked(PInputEvent event) {
				ConnectionMenu.this.remove();
			}
		});
	}
	
	public Block getStartingBlock() {
		return startingBlock;
	}
	
	public Block getTargetBlock() {
		return targetBlock;
	}	
	
	@Override
	public void remove() {
		this.finished.run();
		super.remove();
	}
}
